package com.zyd.blog.personal.controller;

import com.alibaba.fastjson.JSON;
import com.zyd.blog.personal.po.CompanyInfoPo;
import com.zyd.blog.personal.service.BigPlotformService;
import com.zyd.blog.personal.utils.JavaBeanAndMapUtils;
import com.zyd.blog.personal.utils.RespResultUtils;
import com.zyd.blog.personal.vo.ResponseResultVo;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Map;

/**
 * 协议查询
 * @author mfy
 */
@RestController
@RequestMapping("/plotform")
public class ProtocolController {

    @Resource
    private BigPlotformService bigPlotformService;


    /**
     * 得到商家合作协议内容
     * 访问路径 http://localhost:8443/plotform/getMerchantCooperationProtocol
     * @return  协议内容
     */
    @RequestMapping("/getMerchantCooperationProtocol")
    public ResponseResultVo getMerchantCooperationProtocol(){
        return RespResultUtils.getSuccessData(bigPlotformService.getMerchantCooperationProtocol("MerchantCooperation"));
    }

    /**
     * 得到申请设计师申请协议内容
     * 访问路径 http://localhost:8443/plotform/getApplyDesignProtocol
     * @return  协议内容
     */
    @RequestMapping("/getApplyDesignProtocol")
    public Object getApplyDesignProtocol(){
        return RespResultUtils.getSuccessData(bigPlotformService.getMerchantCooperationProtocol("ApplyDesign"));
    }

    /**
     * 得到商家合作说明
     * 访问路径 http://localhost:8443/plotform/getCooperationDescription
     * @return  协议内容
     */
    @RequestMapping("/getCooperationDescription")
    public Object getCooperationDescription(){
        return RespResultUtils.getSuccessData(bigPlotformService.getMerchantCooperationProtocol("cooperationDescription"));
    }

    /**
     * 得到商家合作说明
     * 访问路径 http://localhost:8443/plotform/getMerchantCooperationDescription1
     * @return  商家合作说明
     */
    @RequestMapping("/getMerchantCooperationDescription1")
    public Object getMerchantCooperationDescription1(){
        return RespResultUtils.getSuccessData(bigPlotformService.getMerchantCooperationDescription());
    }

    /**
     * 得到商家合作说明
     * 访问路径 http://localhost:8443/plotform/getMerchantCooperationDescription
     * @return  商家合作说明
     */
    @RequestMapping("/getMerchantCooperationDescription")
    public Object getMerchantCooperationDescription(){
        CompanyInfoPo result = bigPlotformService.getMerchantCooperationDescription();
        String advantage = result.getAdvantage();
        String description = result.getDescription();
        String process = result.getProcess();
        String contact = result.getContact();

        Map<String,Object> map = JavaBeanAndMapUtils.javaBeanToMap(result);
        map.put("advantage",JSON.parseObject(advantage));
        map.put("description",JSON.parseObject(description));
        map.put("process",JSON.parseObject(process));
        map.put("contact",JSON.parseObject(contact));

        return RespResultUtils.getSuccessData(map);
    }

}
